package com.yc;

import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;

/**
 * @author zwei
 * @create 2024-07-18 15:09
 */
public class Test2_clinet {
    //编写野狗客户端
    public static void main(String[] args) throws IOException {
        InetAddress[] ia2=InetAddress.getAllByName("www.baidu.com");
        if (ia2!=null){
            //baidu服务器的ip有多个
            for (InetAddress ia:ia2){
                Socket client=new Socket(ia,80);
                System.out.println("连接成功，"+client);
                break;
            }
        }

        Socket client2=new Socket("www.baidu.com",80);
        System.out.println("连接成功2，"+client2);

        Socket client3=new Socket("60.205.91.68",8080);
        System.out.println("连接成功3，"+client3);
    }
}
